﻿@using PlatformNetCore.Entity
@{
    ViewBag.Title = "编辑招聘信息";
}
@model Jobs
<style>
    html {
        background-color: #fff;
    }

    .layui-card {
        box-shadow: none;
    }
</style>
<!-- 配置文件 -->
<script src="~/lib/ckeditor/ckeditor.js"></script>

<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="@Url.Action("JobsEdit","Jobs",new { area = "Admin"})" lay-filter="useredit-form">
            <div class="layui-form-item">
                <label class="layui-form-label">标题*</label>
                <div class="layui-input-block">
                    <input type="hidden" name="ID" lay-verify="required" autocomplete="on" class="layui-input">
                    <input type="text" name="Title" lay-verify="required" placeholder="标题" autocomplete="on" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">职能类型</label>
                <div class="layui-input-block">
                    <select name="JobID" lay-filter="JobID" lay-search>
                        @foreach (var item in (List<SelectListItem>)ViewBag.JobsTypeDLL)
                        {
                            <option value="@item.Value">@item.Text</option>
                        }
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">职位类型</label>
                <div class="layui-input-block">
                    <select name="PositionID" lay-filter="PositionID" lay-search>
                        @foreach (var item in (List<SelectListItem>)ViewBag.PositionTypeDLL)
                        {
                            <option value="@item.Value">@item.Text</option>
                        }
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">工作地点*</label>
                <div class="layui-input-block">
                    <input type="text" name="Address" lay-verify="required" placeholder="工作地点" maxlength="50" autocomplete="on" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">部门*</label>
                <div class="layui-input-block">
                    <input type="text" name="Department" lay-verify="required" placeholder="部门" maxlength="100" autocomplete="on" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">招聘人数*</label>
                <div class="layui-input-block">
                    <input type="text" name="JobNumber" value="1" lay-verify="required" placeholder="招聘人数" autocomplete="on" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">发布时间</label>
                <div class="layui-input-block">
                    <input type="text" id="publishDate" name="PublishDate" value='@(Model.PublishDate.HasValue ? Model.PublishDate.Value.ToString("yyyy-MM-dd") : "")' placeholder="发布时间" autocomplete="on" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">是否显示</label>
                <div class="layui-input-block">
                    <input type="checkbox" checked="" name="IsAvailable" value="1" lay-skin="switch" lay-filter="available-Switch" lay-text="显示|隐藏">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">摘要</label>
                <div class="layui-input-block">
                    <textarea type="text" class="layui-textarea" name="Remark" placeholder="摘要"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">排序号</label>
                <div class="layui-input-block">
                    <input type="text" name="SortNo" lay-verify="required" placeholder="排序号" autocomplete="on" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">内容</label>
                <div class="layui-input-block">
                    <!-- 加载编辑器的容器 -->
                    <textarea id="Content" name="Content"></textarea>
                </div>
            </div>
            <div id="useredit-submit" lay-submit lay-filter="useredit-submit"></div>
        </form>
    </div>
</div>
<script>
    CKEDITOR.replace('Content');

    //处理CKEDITOR的值
    function CKUpdate() {
        for (instance in CKEDITOR.instances)
            CKEDITOR.instances[instance].updateElement();
    }

    layui.use(['laydate','form'], function () {
        var $ = layui.$, form = layui.form;
        var laydate = layui.laydate;

        form.render(null, 'useredit-form');

        //执行一个laydate实例
        laydate.render({
            elem: '#publishDate' //指定元素
        });

        /* 监听指定开关 */
        form.on('switch(available-Switch)', function (data) {
            $(this).val(this.checked ? '1' : '0')
        });

        //从父层获取值，json是父层的全局js变量。eval是将该string类型的json串变为标准的json串
        var editObj = parent.editData;
        //表单初始赋值
        form.val('useredit-form', {
            "ID": editObj.ID
            , "Title": editObj.Title
            , "Address": editObj.Address
            , "JobID": editObj.JobID
            , "PositionID": editObj.PositionID
            , "IsAvailable": editObj.IsAvailable
            , "Department": editObj.Department
            , "JobNumber": editObj.JobNumber
            , "Remark": editObj.Remark
            , "SortNo": editObj.SortNo
            , "Content": editObj.Content
        });

    });
</script>
